/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package niezalogowany.dao;

import commons.AbstractDAO;
import commons.DbConnection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import niezalogowany.data.Oferta;

/**
 *
 * @author mbudzilo
 */
public class OfertaDAO  extends AbstractDAO{
        
            public OfertaDAO()
            {
                conn = DbConnection.getConnection();
            }
            
            public ArrayList<Oferta> getListaKsiazek(String s)
            {
            ArrayList<Oferta> list = new ArrayList<Oferta>();
      
           
                try {
                      query ="select ofe_id ,"
                              + " wyc_id,"
                              + " ofe_nazwa,"
                              + " ofe_opis,"
                              + " wyc_cena,"
                              + " wyc_wylot,"
                              + " wyc_przylot,"
                              + " wyc_rozpoczecie,"
                              + " wyc_zakonczenie from oferta left JOIN wycieczka wyc_rozpoczecie" ;                    
                   
                    prepStmt = conn.prepareStatement(query);
                     //prepStmt.setString(1, s+"%");
                     rs = prepStmt.executeQuery();
                      
                     while(rs.next())
                     {     
                         Oferta data = new Oferta();
                         data.setOfeId(rs.getInt(1));
                         data.setWycId(rs.getInt(2));
                         data.setOfeNazwa(rs.getString(3));
                         data.setOfeOpis(rs.getString(4));
                         data.setWycCena(rs.getBigDecimal(5));
                         data.setWycWylot(rs.getDate(6));
                         data.setWycPrzylot(rs.getDate(7));
                         data.setWycRozpoczecie(rs.getDate(8));
                         data.setWycZakonczenie(rs.getDate(9));
                         
                       list.add(data);
                         
                     }
                    return list;
                    
                } catch (SQLException ex) {
                    error(ex.getMessage());
                    Logger.getLogger(OfertaDAO.class.getName()).log(Level.SEVERE, null, ex);
                }

           return null;
            }
    
}
